#include "testwidgetplugin.h"
#include <QDebug>
#include <QtPlugin>
#include <QCloseEvent>
#include "ui_testWidgetPlugin.h"

TestWidgetPlugin::TestWidgetPlugin(QWidget *parent):QWidget(parent),ui(new Ui::TestWidgetPlugin)
{
    ui->setupUi(this);
    qDebug() << "testWidgetPlugin Initiated";
    this->cusMenuName = "testWidgetPlugin";
    connect(this,SIGNAL(destroyed()),this,SLOT(deleteing()));
    this->setWindowTitle("This is TestWidgetPlugin");
}

TestWidgetPlugin::~TestWidgetPlugin()
{
    delete ui;
}

void TestWidgetPlugin::load(MainWindow* mv)
{
    qDebug() << "Emitting custom menu name...";
}

QString TestWidgetPlugin::getCustomMenuName()
{
    return this->cusMenuName;
}

QString TestWidgetPlugin::getCustomActionName()
{
    return "testWidget";
}

QString TestWidgetPlugin::getCustomActionPos()
{
    return "&File";
}

QWidget* TestWidgetPlugin::getWidget()
{
    return this;
}

QWidget* TestWidgetPlugin::createWidget(QWidget *parent)
{
    return this;
}


void TestWidgetPlugin::deleteing()
{
    qDebug() << "TestWidgetPlugin is deleted";
}

void TestWidgetPlugin::closeEvent(QCloseEvent *event)
{
    event->accept();
}

Q_EXPORT_PLUGIN2(testwidgetplugin, TestWidgetPlugin);
